<?php
/**
 * Created by PhpStorm.
 * User: 17464
 * Date: 2019/12/30
 * Time: 16:08
 */

namespace App\Http\Transformers\Banner;

use App\Models\Attachment;
use App\Models\Banner;
use League\Fractal\TransformerAbstract;

class BannerDetailTransformer extends TransformerAbstract
{
    public function transform(Banner $banner)
    {
        $data = $banner->toArray();

       $image_attachments= Attachment::find($data['image']);
       $data['image_attachment_data'] = $image_attachments ? $image_attachments->toArray(): [];

        return $data;
    }
}
